﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Chapter17
{
    using Chapter17.View;

    /// <summary>
    /// 第17章 控件模板
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            #region 01 理解逻辑树和可视化树
            #endregion

            #region 02 理解模板
            /*
             * 01 修饰类
             * 02 剖析控件
             * */
            #endregion

            #region 03 创建控件模板
            /*
             * 01 简单按钮
             * 02 模板绑定
             * 03 改变属性的触发器
             * 04 使用动画的触发器
             * */
            #endregion

            #region 04 组织模板资源
            /*
             * 01 分解按钮控件模板
             * 02 通过样式应用模板
             * 03 自动应用模板
             * 04 由用户选择的皮肤
             * */
            #endregion

            #region 05 构建更复杂的模板
            /*
             * 01 嵌套的模板
             * 02 修改滚动条
             * 03 控件模板示例
             * */
            #endregion

            #region 06 可视化状态
            #endregion

            #region 07 小结
            #endregion
        }

        private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Command == ApplicationCommands.Open)
            {
                var button = e.Source as Button;
                if (button != null)
                {
                    if (button == button1)
                    {
                        Demo(new SampleWindow());
                    }
                    if (button == button2)
                    {
                        Demo(new ControlTemplateBrowseWindow());
                    }
                    if (button == button3)
                    {
                        Demo(new SimpleCustomButtonWindow());
                    }
                    if (button == button4)
                    {
                        Demo(new SimpleCustomButton2Window());
                    }
                    if (button == button5)
                    {
                        Demo(new GradientButtonTestWindow());
                    }
                    if (button == button6 || button == button7)
                    {
                        Demo(new GradientButtonTest2Window());
                    }
                    if (button == button8)
                    {
                        Demo(new NestedTemplateWindow());
                    }
                }
            }
        }

        private void Demo(Window window)
        {
            window.Owner = this;
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            window.ShowDialog();
        }
    }
}
